package com.koron.order.common.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.common.bean.po.OrderEquipPo;
import com.koron.order.common.service.OrderEquipService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工单设备表(OrderEquip)表控制层
 *
 * @author zhouj
 * @since 2022-03-16 15:49:19
 */
@Api(tags = "工单设备表(OrderEquip)")
@RestController
@RequestMapping("/orderEquip/")
public class OrderEquipController {

    @Autowired
    private OrderEquipService orderEquipService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改工单设备表")
    @PostMapping("insertOrUpdate")
    public Response<Integer> insertOrUpdate(@RequestBody OrderEquipPo orderEquip) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipService, "insertOrUpdate", Integer.class, orderEquip));
    }

    @ApiOperation(value = "新增工单设备表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody OrderEquipPo orderEquip) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipService, "insert", Integer.class, orderEquip));
    }

    @ApiOperation(value = "批量新增工单设备表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<OrderEquipPo> orderEquipList) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipService, "insertBatch", Integer.class, orderEquipList));
    }

    @ApiOperation(value = "根据id更新工单设备表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody OrderEquipPo orderEquip) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipService, "update", Integer.class, orderEquip));
    }

    @ApiOperation(value = "根据id删除工单设备表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询工单设备表")
    @GetMapping("queryById")
    public Response<OrderEquipPo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipService, "queryById", OrderEquipPo.class, id));
    }

    @ApiOperation(value = "不分页查询工单设备表列表")
    @GetMapping("queryList")
    public Response<List> queryList(OrderEquipPo queryVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询工单设备表列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(OrderEquipPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

}
